﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class ChangePassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void btnChangePassword_Click(object sender, EventArgs e)
    {
        User user = new User();

        if (EventDAO.isValidUser(LoginName.Text.ToLower()))
        {
            user = EventDAO.getUserByName(LoginName.Text.ToLower());

            // Password is matching to the user
            if (user.password.Equals(Password.Text))
            {
                EventDAO.updateUserPassword(LoginName.Text.ToLower(), NewPassword.Text);
                lblStatus.Text = "Password changed succesfully. Please go to Home page and login with the new password.";
                lnkBtnLogin.Visible = true;
            }
            else
            {
                ErrorMessage.Text = "User/Password is incorrect.";
            }
        }
    }
}
